import React from 'react';
import { observer, inject } from 'mobx-react';
import { Checkbox } from 'weaver-mobile';

@inject('wfLayoutStore')
@observer
export default class CheckElement extends React.Component{
    doChangeEvent(e){
        const value = e.target.checked ? "1" : "0";
        const { fieldMark,wfLayoutStore } = this.props;
		wfLayoutStore.changeSingleFieldValue(fieldMark, {value: value});
	}
    render() {
        const { fieldMark,fieldValue,viewAttr,symbol,rowIndex } = this.props;
        return(
            [<Checkbox
                disabled={viewAttr<=1}
                checked={fieldValue=="1"}
                onChange={this.doChangeEvent.bind(this)}
            />,<input type="hidden" id={fieldMark} name={fieldMark} value={fieldValue} />]
        )
    }
}